//
//  MPViewController.m
//  MPTCustomUILibrary
//
//  Created by jxzjxz on 08/09/2017.
//  Copyright (c) 2017 jxzjxz. All rights reserved.
//

#import "MPViewController.h"
#import "MPCActionSheet.h"
#import "MPBColor.h"
#import "MPBConfig.h"

#import "UIFont+Tools.h"
#import "Masonry.h"
#import "MPCPageLoadingView.h"
#import "MPTableViewController.h"
#import <MPCToast.h>


@interface MPViewController ()<MPCActionSheetDelegate>

@property (weak, nonatomic) IBOutlet UIView *loadingView;
@property (nonatomic, strong) MPCPageLoadingView *pageLoadingView;

@end

@implementation MPViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // loadView
    self.pageLoadingView = [[MPCPageLoadingView alloc]init];
    self.title = @"Example";
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)actionSheet:(id)sender
{
//    MPCActionSheet *sheet = [MPCActionSheet sheetWithImages:@[@"shou", @"dow"]
//                                          otherButtonTitles:@[@"收藏到影单", @"缓存"]
//                                                   delegate:self];
//    [sheet show];

    UIView *cview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 120.0f)];
    cview.backgroundColor = [UIColor redColor];
    
    UIImageView *imv = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
    imv.center = cview.center;
    imv.image = [UIImage imageNamed:@"shou"];
    [cview addSubview:imv];
    
    
    MPCActionSheetConfig *config = [[MPCActionSheetConfig alloc]init];
    config.buttonColor = [UIColor redColor];
    MPCActionSheet *sheet = [MPCActionSheet sheetWithCustomView:cview customsConfig:config cancelButtonTitle:@"取消" delegate:self otherButtonTitles:@"关注",@"不关注", nil];

    [sheet show];
}

- (IBAction)actionsheetC2:(id)sender
{
    MPCActionSheet *actionSheet = [MPCActionSheet sheetWithTitle:@"Title"
                                                        delegate:self
                                               cancelButtonTitle:@"取消"
                                               otherButtonTitles:@"拍摄",@"相册", nil];
    [actionSheet show];
}

- (IBAction)C1Action:(id)sender
{
    if (self.pageLoadingView.superview == nil)
    {
        [self.loadingView addSubview:self.pageLoadingView];
        
        [self.pageLoadingView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.loadingView);
        }];
    }
    
    self.pageLoadingView.centerY = YES;
    
    [self.pageLoadingView showNonNetViewWithImageName:@"mp_net_error" hintTitle:@"没有网络" buttonTitle:@"点击刷新" action:^{
        NSLog(@"gogo");
    }];

//    [self.pageLoadingView showHudWithImageName:@"common_comments_loading" title:@"加载中"];
}

- (IBAction)C2Action:(id)sender
{
    [self.pageLoadingView removePageLoadingView];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (self.pageLoadingView.superview == nil)
        {
            [self.loadingView addSubview:self.pageLoadingView];
            
            [self.pageLoadingView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(self.loadingView);
            }];
        }
        
        [self.pageLoadingView showFailViewWithHintTitle:@"评论错误" buttonTitle:@"点击重试" action:^{
          NSLog(@"gogo");
       }];
    });
}

- (IBAction)C3Action:(id)sender
{
    if (self.pageLoadingView.superview == nil)
    {
        [self.loadingView addSubview:self.pageLoadingView];
        
        [self.pageLoadingView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.loadingView);
        }];
    }

    [self.pageLoadingView showNotDataViewWithImageName:@"shimmerLogo" hintTitle:@"无数据 " action:^{
        NSLog(@"gogo");
    }];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.pageLoadingView showRetryButton:@"评论加载失败,点击重试" action:^{
            NSLog(@"gogo");
        }];
    });
}

- (IBAction)C4Action:(id)sender
{
    if (self.pageLoadingView.superview == nil)
    {
        [self.loadingView addSubview:self.pageLoadingView];
        
        [self.pageLoadingView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.loadingView);
        }];
    }
    
    [self.pageLoadingView showLoadingViewWithImageName:@"深色" shineImageName:@"浅色"];
}

- (IBAction)navigationBarTest:(id)sender
{   
    MPTableViewController *con = [[MPTableViewController alloc] init];
    [self.navigationController pushViewController:con animated:YES];
}


@end
